package net.model;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Embeddable
public class HistogramClasePK implements Serializable {

	private static final long serialVersionUID = 6927280104810668988L;

	@ManyToOne
	@JoinColumn(name = "ID_HISTOGRAMA", insertable = false, updatable = false, nullable = false)
	private Histogram histogram;

	@ManyToOne
	@JoinColumn(name = "ID_CLASE", insertable = false, updatable = false, nullable = false)
	private Clase clase;

	public HistogramClasePK() {
		super();
	}

	public HistogramClasePK(Clase clase, Histogram histogram) {
		super();
		this.clase = clase;
		this.histogram = histogram;
	}

	public Clase getClase() {
		return clase;
	}

	public void setClase(Clase clase) {
		this.clase = clase;
	}

	public Histogram getHistogram() {
		return histogram;
	}

	public void setHistogram(Histogram histogram) {
		this.histogram = histogram;
	}

	public boolean equals(Object o) {
		if (o == null)
			return false;
		if (!(o instanceof HistogramClasePK))
			return false;
		HistogramClasePK r = (HistogramClasePK) o;
		if (getClase() != null && getHistogram() != null)
			return getClase().equals(r.getClase())
					&& getHistogram().equals(r.getHistogram());
		return false;
	}

	public int hashCode() {
		return getClase().hashCode() + getHistogram().hashCode();
	}

	public String toString() {
		if (getClase() != null && getHistogram() != null)
			return getClase().getNombre() + " - " + getHistogram().getTipo();
		return "";
	}
}
